var api = require('../../utils/api.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [{
        icon: "https://www.boxnearby.com/images/company.png",
        title: "Boxnearby-美东智能快递柜项目",
        host_image: "https://www.boxnearby.com/images/page-1_slide04.png",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
      {
        icon: "http://pc56u8l1n.bkt.clouddn.com/smartBox_logo_512.png",
        title: "联友魔盒",
        host_image: "http://pc56u8l1n.bkt.clouddn.com/smartBox_host.jpg",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
      {
        icon: "http://pc56u8l1n.bkt.clouddn.com/po_icon_200.png",
        title: "柚子社团",
        host_image: "http://pc56u8l1n.bkt.clouddn.com/youzi_host.jpg",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
      {
        icon: "https://iot.mi.com/new/static/img/cloud_to_cloud.ad8e890.png",
        title: "*花园19栋2单元*2智能家居方案设计",
        host_image: "https://iot.mi.com/new/static/img/cloud_to_cloud.ad8e890.png",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
      {
        icon: "http://pc56u8l1n.bkt.clouddn.com/proke_1024_icon.png",
        title: "专业课",
        host_image: "http://pc56u8l1n.bkt.clouddn.com/kaoyanbox_host.png",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
      {
        icon: "http://pc56u8l1n.bkt.clouddn.com/yanzhao_icon.png",
        title: "研*网全站数据爬虫及清洗",
        host_image: "http://pc56u8l1n.bkt.clouddn.com/yanzhao_host.jpg",
        left_txt: "查看设计图",
        right_txt: "进入详细模块设计"
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var self = this
    wx.setNavigationBarTitle({
      title: "项目案例"
    })
    api.db.collection('project_info').where({})
      .orderBy('index1', 'asc')
      .get()
      .then(res => {
        // console.log()
        self.setData({
          list: res.data
        })
      })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  showProgramDetail: function (e) {
    wx.navigateTo({
      url: '/pages/singleProject/singleProject?id=' + this.data.list[e.currentTarget.id]._id + "&name=" + this.data.list[e.currentTarget.id].title,
    })
  }
})